package com.platform.service.impl;

import com.platform.dao.EmceeAdDao;
import com.platform.entity.EmceeAdEntity;
import com.platform.service.EmceeAdService;
import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author ocean
 * @email 1141736487@qq.com
 * @date 2019-03-13 15:06:50
 */
@Service("EmceeAdService")
public class EmceeAdServiceImpl implements EmceeAdService {
    @Autowired
    private EmceeAdDao adDao;

    @Override
    public EmceeAdEntity queryObject(Integer id) {
        return adDao.queryObject(id);
    }

    @Override
    public List<EmceeAdEntity> queryList(Map<String, Object> map) {
        long userId = ShiroUtils.getUserId();
        if(userId == 1){
            map.put("createUser", null);
        }else {
            map.put("createUser", userId);
        }
        return adDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return adDao.queryTotal(map);
    }

    @Override
    public int save(EmceeAdEntity ad) {
        long userId = ShiroUtils.getUserId();
        ad.setCreateUser((int)userId);
        ad.setCreateTime(new Date());
        return adDao.save(ad);
    }

    @Override
    public int update(EmceeAdEntity ad) {
        return adDao.update(ad);
    }

    @Override
    public int delete(Integer id) {
        return adDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return adDao.deleteBatch(ids);
    }
}
